//
//  YSDefines.h
//  luGongPro
//
//  Created by 王庆学 on 2017/7/31.
//  Copyright © 2017年 王庆学. All rights reserved.
//
//#ifdef DEBUG
#define LGlog(...) NSLog(__VA_ARGS__);
#define EFSLogH(URLSTRING, REQUESTMETHOD, PARAMS, RESULT, ERROR) \
[[EFSLogger shared] logURLString:URLSTRING requestMethod:REQUESTMETHOD params:PARAMS result:RESULT error:ERROR extra:EXTRALog];
#define EFSLog(fmt, ...) NSLog((@"%s %s [ LINE %d ]\n" fmt), [[[NSString stringWithUTF8String:__FILE__]lastPathComponent] UTF8String],__FUNCTION__,__LINE__, ##__AV_ARGS__);

#define NavigationAndStatusHeight 64.f
#define TarBarHeight 49.f
#define kLoginNavHeadViewHeight (self.view.bounds.size.widht * 454 / 750)
#define kDefaultPreloadConfigKey @"kDefaultPreloadConfigKey"

#define kWidth  [UIScreen mainScreen].bounds.size.width
#define kHeight [UIScreen mainScreen].bounds.size.height

#define SCREEN_MAX_LENGTH MAX(kWidth, kHeight)

#define IS_IPHONE_5 (SCREEN_MAX_LENGTH == 568.0)

#define scrFont (IS_IPHONE_5?1.0:0)
#define kCOLOR(ColorName) [UIColor ColorName]
#define kRGBCOLOR(r,g,b)  [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define kRGBACOLOR(r,g,b,a)  [UIColor colorWithRed:(r)/255.0f green:(g)255.0f blue:(b)/255.0f alpha:(a)]
#define UIColorWithHex(x) kRGBCOLOR(((x)&0xFF0000) >> 16, ((x)&0xFF00) >>8, ((x)&0xFF))

#define kIMAGE(ImageName) [UIImage imageNamed:ImageName]
#define kFONT(FontSize)   [UIFont systemFontOfSize:FontSize]
#define kBOLDFONT(FontSize)  [UIFont boldSystemFontOfSize:FontSize]
#define kSEL(SELName)     @selector(SELName)
#define kPoint(x,y)       CGPointMake(x,y)
#define kFrame(x,y,width,height)  CGRectMake(x, y, widht, height)
#define kSize(widht,height)       CGSizeMake(widht,height)
#define kBOUNDS                   self.view.bounds

#define kAlert(title,msg,cancelTitle,...) UIAlertView *alertView = [UIAlertView alloc]initWithTitle:title message:msg delegate:self cancelButtonTitle:cancelTitle otherButtonTitles:__VA_ARGS__, nil];\
[alertView show]

#define EFS_ERROR_MESSAGE_KEY @"message"

#define SYSTEM_VERSION_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)    ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)   ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

#define objectOrNull(obj) ((obj) ? (obj) : [NSNull null])
#define objectOrEmptyStr(obj) ((obj != nil) ? (obj) : @"")
#define objectOrEmptyNSNumber(Obj) ((obj) ? (obj) : @0)

#define KEYWINDOW  [[UIApplication sharedApplication] keyWindow]
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]

#define RADIANS_TO_DEGREES(x) ((x)/M_PI*180.0)
#define DEGREES_TO_RADIANS(x) ((x)/180.0*M_PI)

#define fequal(a,b) (fabs((a) -(b)) < DBL_EPSILON)
#define fequalzero(a) (fabs(a) < FLT_EPSILON)
#define flessthan(a,b) (fabs(a) < fabs(b)+FLT_EPSILON)

//转成字符串
#define STRINGIFY(S) #S
//需要解两次才解开的宏
#define DEFER_STRINGIFY(S) STRINGIFY(S)
#define PRAGMA_MESSAGE(MSG) _Pragma(STRINGIFY(message(MSG)))
//为warning增加更多信息
#define FORMATTED_MESSAGE(MSG) "[TODO-" DEFER_STRINGIFY(__COUNTER__) "] " MSG " \n line " DEFER_STRINGIFY(__LINE__)
// 使宏前面可以加@
#define KEYWORDIFY try {} @catch (...) {}
// 最终使用的宏
#define TODO(MSG) KEYWORDIFY PRAGMA_MESSAGE(FORMATTED_MESSAGE(MSG))

#define GLOBALSETTING @"globalSetting"
#define CONFIGURL @"efs_config_url"

